package lesson3;

import java.util.LinkedList;
import java.util.Queue;

public class MyQueue {

    private Queue<String> queue = new LinkedList<>();

    public void give(String data){
        queue.add(data);
        notify();
    }

    public void take(){
        if(queue.isEmpty()){
            try {
                wait();
                return;
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        queue.remove();
    }

    public static void main(String[] args) {
        MyQueue myQueue = new MyQueue();
        myQueue.give("123");

        myQueue.take();
    }
}
